package com.medical.goods.service.impl;

import com.medical.goods.dao.TypeDao;
import com.medical.goods.entity.TypeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.medical.common.utils.PageUtils;
import com.medical.common.utils.Query;

import com.medical.goods.dao.CommodityDao;
import com.medical.goods.entity.CommodityEntity;
import com.medical.goods.service.CommodityService;


@Service("commodityService")
public class CommodityServiceImpl extends ServiceImpl<CommodityDao, CommodityEntity> implements CommodityService {

    @Autowired
    private CommodityDao commodityDao;

    @Autowired
    private TypeDao typeDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CommodityEntity> page = this.page(
                new Query<CommodityEntity>().getPage(params),
                new QueryWrapper<CommodityEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<CommodityEntity> check(Integer tid,String name) {
        return commodityDao.check(tid,name);
    }

    @Override
    public void add(CommodityEntity commodity) {
        //添加商品
        commodityDao.insert(commodity);
    }

    @Override
    public void updates(CommodityEntity commodity) {

        //修改商品信息
        commodityDao.updateById(commodity);
    }

    @Override
    public void delete(Integer id) {
        //删除商品
        commodityDao.deleteById(id);



    }


}